package com.ym.controller.soso;

import com.github.pagehelper.PageInfo;
import com.ym.common.constant.Constants;
import com.ym.common.utils.page.PageDomain;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.soso.domain.entity.AedInfoEntity;
import com.ym.soso.domain.param.AedInfoQueryParam;
import com.ym.soso.domain.vo.AedInfoListPcVO;
import com.ym.soso.enums.PublishStatusEnum;
import com.ym.soso.service.IAedInfoSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * AED信息管理
 *
 * @author: 李涛
 * @version: 2019年06月24日 14:45
 */
@Api(tags = "APP-AED信息管理")
@RestController("AppAedInfoController")
@RequestMapping(value = "/soso/app/aed/info", headers = Constants.Api.VERSION)
@Validated
public class AedInfoController extends BaseController {


	@Autowired
	private IAedInfoSV aedInfoSV;

	@Log(dataBase = true, printBody = false)
	@ApiOperation("AED列表")
	@GetMapping(value = "/list")
	public APIResponse<PageInfo<AedInfoListPcVO>> list(
			@Valid AedInfoQueryParam queryParams
	) {
		PageDomain.startPage();
		queryParams.setPublishStatus(PublishStatusEnum.HAS_BEEN_RELEASED.getKey());
		List<AedInfoListPcVO> datas = aedInfoSV.selectListPC(queryParams);
		return successPage(datas);
	}

	@Log(dataBase = true, printBody = false)
	@ApiOperation("AED详情")
	@GetMapping(value = "/view")
	public APIResponse<AedInfoEntity> view(
			@RequestParam Long id
	) {
		AedInfoEntity data = aedInfoSV.selectById(id);
		return successData(data);
	}

}
